<!doctype html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>Document</title>
	</head>
	<body>
		<input id='btn' type="button" value='获取彩票号码'/>
		<div id='box'></div>
		<script type="text/javascript">
			var json = {};
			btn.onclick = function(){
				//console.log( ranDom(31,7) );	
				var num = Math.random();
				var arr = ranDom(31,7);
				json[num] = arr;
				box.innerHTML = arr;
				window.location.hash = num;
			};
			window.onhashchange = function(){
				//console.log( json )
				box.innerHTML = json[window.location.hash.substring(1)];
			};

			function ranDom(iAll,iNow){
				var arr = [];
				var newArr = [];
				for( var i=0;i<iAll;i++ ){
					arr.push(i);
				}
				for( var i=0;i<iNow;i++ ){
					newArr.push( arr.splice(arr[Math.floor(Math.random()*arr.length)],1) );
				}
				return newArr;
			}
		</script>
	</body>
</html>
